﻿using System;

namespace TinyForum.DataObjects
{
    /// <summary>
    /// Represents the data object that contains the application fault details.
    /// </summary>
    partial class ApplicationFaultDetail
    {
        #region Ctor
        /// <summary>
        /// Initializes a new instance of <c>ApplicationFaultDetail</c> class.
        /// </summary>
        public ApplicationFaultDetail()
        { }
        /// <summary>
        /// Initializes a new instance of <c>ApplicationFaultDetail</c> class.
        /// </summary>
        /// <param name="ex">The exception instance for which the <c>ApplicationFaultDetail</c> is created.</param>
        /// <param name="faultSource">The source of the fault.</param>
        public ApplicationFaultDetail(Exception ex, FaultSourceType faultSource)
        {
            this.DetailField = ex.ToString();
            this.ExceptionTypeField = ex.GetType().AssemblyQualifiedName;
            this.FaultSourceField = faultSource;
            this.MessageField = ex.Message;
            this.StackTraceField = ex.StackTrace;
        }
        /// <summary>
        /// Initializes a new instance of <c>ApplicationFaultDetail</c> class.
        /// </summary>
        /// <param name="ex">The exception instance for which the <c>ApplicationFaultDetail</c> is created.</param>
        public ApplicationFaultDetail(Exception ex)
            :this(ex, FaultSourceType.Application)
        {

        }
        #endregion
    }
}
